$.extend({// 获取http请求参数
	getUrlVars : function() {
		var vars = [], hash;
		var hashes = window.location.href.slice(
				window.location.href.indexOf('?') + 1).split('&');
		for (var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	getUrlVar : function(name) {
		return $.getUrlVars()[name];
	}
});
function addShade() {
	$("<div class='layui-layer-shade' times='2'>").css({
		"z-index" : "19891015",
		"background-color" : "#000",
		"opacity" : "0.3",
		"filter" : "alpha(opacity=30)"
	}).appendTo($("body"));
}
function removeShade() {
	$(".layui-layer-shade").remove();
}
function ajaxPost(param, action, successMethod) {
	$.ajax({
		type : "POST",
		url : action,
		dataType : "json",
		data : param,
		success : successMethod,
		timeout : 30000,
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			// location.href = "/web/web.html?index=1";
		}
	});
}
function log(data) {
	console.log(JSON.stringify(data))
}
function setCookie(name, value) {
	var Days = 30;
	var exp = new Date();
	exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
	document.cookie = name + "=" + escape(value) + ";expires="
			+ exp.toGMTString();
}
function isAllChinese(str) {// 是否全是中文
	var reg = /^[\u4E00-\u9FA5]+$/;
	if (!reg.test(str)) {
		return false;
	} else {
		return true;
	}
}
function checkAccount(str) {// 字母数字下划线组合
	var regex = /^[A-Za-z0-9_]+$/ig;
	if (str.length < 6)
		return false;
	if (!regex.test(str)) {
		return false;
	} else {
		return true;
	}
}
function getCookie(name) {
	var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
	if (arr = document.cookie.match(reg))
		return unescape(arr[2]);
	else
		return null;
}
function checkPhone(phone) {
	var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
	if (!myreg.test(phone)) {
		return false;
	}
	return true;
}
function checkPersonCode(code) {
	var reg = /^\d{6}(19|20)?\d{2}(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])\d{3}(\d|X)$/i;
	if (reg.test(code) === false) {
		return false;
	}
	return true;
}
function isEmail(str) {
	var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	return reg.test(str);
}
function getModule(list) {
	firstList = [];
	allData = {}, allList = [];
	// allList = list;
	for ( var k in list) {
		var item = list[k];
		if (item.node == 1) {
			var key = item.mid;
			var obj = {};
			obj[key] = [];
			firstObj[key] = firstList.length;
			firstList.push(obj);
		}
	}
	for ( var k in list) {
		var item = list[k];
		allData[item.mid] = item;
		if (item.node == 1) {

		} else if (item.node == 2) {
			var parentId = item.parentId;
			var index = firstObj[parentId];
			console.log(index);
			var obj = firstList[index];
			var array = obj[parentId];
			if (!array)
				array = [];
			array.push(item.mid);
			obj[parentId] = array;
			firstList[index] = obj;
			secondList.push(item);
		} else {
			alert("数据格式错误");
			break;
		}
	}

	// for ( var i in firstList) {
	// var obj = firstList[i];
	// var key;
	// for ( var k in obj) {
	// key = k;
	// }
	// var childList = obj[key];
	// if (childList.length > 0) {
	// allData[key].first = "1";
	// }
	// allList.push(allData[key]);
	// for ( var j in childList) {
	// allData[childList[j]].second = "1";
	// allList.push(allData[childList[j]]);
	// }
	// }
	return firstList;
}
Date.prototype.Format = function(fmt) { // author: meizz
	var o = {
		"M+" : this.getMonth() + 1, // 月份
		"d+" : this.getDate(), // 日
		"h+" : this.getHours(), // 小时
		"m+" : this.getMinutes(), // 分
		"s+" : this.getSeconds(), // 秒
		"q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
		"S" : this.getMilliseconds()
	// 毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	for ( var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
					: (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}